package com.mapper;

import com.entity.TAuthor;
import com.entity.TAuthorExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TAuthorMapper {
    @SelectProvider(type=TAuthorSqlProvider.class, method="countByExample")
    int countByExample(TAuthorExample example);

    @DeleteProvider(type=TAuthorSqlProvider.class, method="deleteByExample")
    int deleteByExample(TAuthorExample example);

    @Delete({
        "delete from t_author",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into t_author (uid, nick, ",
        "follower_amount, fans_amount, ",
        "visitor_amount, update_time)",
        "values (#{uid,jdbcType=VARCHAR}, #{nick,jdbcType=VARCHAR}, ",
        "#{followerAmount,jdbcType=INTEGER}, #{fansAmount,jdbcType=INTEGER}, ",
        "#{visitorAmount,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(TAuthor record);

    @InsertProvider(type=TAuthorSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(TAuthor record);

    @SelectProvider(type=TAuthorSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.VARCHAR),
        @Result(column="nick", property="nick", jdbcType=JdbcType.VARCHAR),
        @Result(column="follower_amount", property="followerAmount", jdbcType=JdbcType.INTEGER),
        @Result(column="fans_amount", property="fansAmount", jdbcType=JdbcType.INTEGER),
        @Result(column="visitor_amount", property="visitorAmount", jdbcType=JdbcType.INTEGER),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TAuthor> selectByExample(TAuthorExample example);

    @Select({
        "select",
        "id, uid, nick, follower_amount, fans_amount, visitor_amount, update_time",
        "from t_author",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.VARCHAR),
        @Result(column="nick", property="nick", jdbcType=JdbcType.VARCHAR),
        @Result(column="follower_amount", property="followerAmount", jdbcType=JdbcType.INTEGER),
        @Result(column="fans_amount", property="fansAmount", jdbcType=JdbcType.INTEGER),
        @Result(column="visitor_amount", property="visitorAmount", jdbcType=JdbcType.INTEGER),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    TAuthor selectByPrimaryKey(Integer id);

    @UpdateProvider(type=TAuthorSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TAuthor record, @Param("example") TAuthorExample example);

    @UpdateProvider(type=TAuthorSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") TAuthor record, @Param("example") TAuthorExample example);

    @UpdateProvider(type=TAuthorSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TAuthor record);

    @Update({
        "update t_author",
        "set uid = #{uid,jdbcType=VARCHAR},",
          "nick = #{nick,jdbcType=VARCHAR},",
          "follower_amount = #{followerAmount,jdbcType=INTEGER},",
          "fans_amount = #{fansAmount,jdbcType=INTEGER},",
          "visitor_amount = #{visitorAmount,jdbcType=INTEGER},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(TAuthor record);

    @Select({
            "select",
            "id, uid, nick, follower_amount, fans_amount, visitor_amount, update_time",
            "from t_author",
            "ORDER BY id DESC LIMIT 1"
    })
    TAuthor selectNewest();
}